/**
 * 
 */
package cn.com.gzheroli.bfw.service.impl;

import java.util.List;

import javax.servlet.http.HttpSession;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.com.gzheroli.bfw.pojo.base.TSUser;
import cn.com.gzheroli.cache.SpringRedisCache;
import cn.com.gzheroli.core.manager.Client;
import cn.com.gzheroli.core.util.ContextHolderUtils;
import cn.com.gzheroli.service.bfw.RedisCacheService;

/**
 * @author Administrator
 *
 */
@Service("redisCacheService")
@com.alibaba.dubbo.config.annotation.Service
public class RedisCacheServiceImpl implements RedisCacheService{
	private static final Logger logger = Logger.getLogger(RedisCacheServiceImpl.class);
	@Autowired
    private  SpringRedisCache cache;
	@Override
	public TSUser getSessionUserName(String sessionId) {
		//HttpSession session = ContextHolderUtils.getSession();
		Client client=cache.getCache(sessionId, Client.class);
		if(client!=null)
			return client.getUser();
		return null;
	}

	@Override
	public <T> boolean putCache(String key, T obj) {
		// TODO Auto-generated method stub
		return cache.putCache(key, obj);
	}

	@Override
	public <T> void putCacheWithExpireTime(String key, T obj, long expireTime) {
		// TODO Auto-generated method stub
		cache.putCacheWithExpireTime(key, obj, expireTime);
	}

	@Override
	public <T> boolean putListCache(String key, List<T> objList) {
		// TODO Auto-generated method stub
		return cache.putListCache(key, objList);
	}

	@Override
	public <T> boolean putListCacheWithExpireTime(String key, List<T> objList, long expireTime) {
		// TODO Auto-generated method stub
		return cache.putListCacheWithExpireTime(key, objList, expireTime);
	}

	@Override
	public <T> T getCache(String key, Class<T> targetClass) {
		// TODO Auto-generated method stub
		return cache.getCache(key, targetClass);
	}

	@Override
	public <T> List<T> getListCache(String key, Class<T> targetClass) {
		// TODO Auto-generated method stub
		return cache.getListCache(key, targetClass);
	}

	@Override
	public void deleteCache(String key) {
		// TODO Auto-generated method stub
		cache.deleteCache(key);
	}

	@Override
	public void deleteCacheWithPattern(String pattern) {
		// TODO Auto-generated method stub
		cache.deleteCacheWithPattern(pattern);
	}

	@Override
	public void clearCache() {
		// TODO Auto-generated method stub
		cache.clearCache();
	}
	@Override
  public boolean containsKey(String key) {
		return cache.containsKey(key);
    }

}
